package main.java.game;


import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import main.java.game.combatant.Combatant;
import main.java.game.combatant.Hero;
import main.java.game.combatant.Monster;
import main.java.game.item.Armour;
import main.java.game.item.Equipable;
import main.java.game.item.Shield;
import main.java.game.item.Treasure;
import main.java.game.item.Weapon;
import main.java.game.item.equipableTreasure.CloakTreasure;
import main.java.game.item.equipableTreasure.EquipableTreasure;
import main.java.game.item.potion.Potion;
import main.java.game.item.sorcery.Sorcery;
import main.java.game.location.Location;


/**
 * @author   Microsoft Corporation
 */
public class Player{
	/**
	 * @uml.property  name="name"
	 */
	private String name;
	
	private List<Equipable> equipables = new LinkedList<Equipable>();
	
	private List<Treasure> usedTreasures = new LinkedList<Treasure>();
	
	public List<Equipable> getEquipables(){
		return equipables;
	}
	private List<Sorcery> sorceriesUnavaiables= new LinkedList<Sorcery>();
	private List<Location> locations;
	
	public List<Location> getLocations(){
		return locations;
	}
	
	public Player(Hero initialHero,String name){
		this.heros=new LinkedList<Hero>();
		this.potions=new LinkedList<Potion>();
		this.sorceries=new LinkedList<Sorcery>();
		this.armours=new LinkedList<Armour>();
		this.weapons=new LinkedList<Weapon>();
		this.shields=new LinkedList<Shield>();
		this.locations=new LinkedList<Location>();
		
		this.heros.add(initialHero);
		this.gold = 50;
		this.name=name;
		
		
		
	}
	/**
	 * @return
	 * @uml.property  name="name"
	 */
	public String getName(){
		return name;
	}

	/**
	 * Returns <tt>true</tt> if this collection contains no elements.
	 * @return  <tt>true</tt> if this collection contains no elements
	 * @see java.util.Collection#isEmpty()
	 * @uml.property  name="heroes"
	 */
	public boolean isHerosEmpty() {
		return heros.isEmpty();
	}

	/**
	 * Returns <tt>true</tt> if this collection contains the specified element. 
	 * @param element  whose presence in this collection is to be tested.
	 * @see java.util.Collection#contains(Object)
	 * @uml.property  name="heroes"
	 */
	public boolean containsHero(Combatant hero) {
		return this.heros.contains(hero);
	}

	/**
	 * Returns <tt>true</tt> if this collection contains all of the elements in the specified collection.
	 * @param elements  collection to be checked for containment in this collection.
	 * @see java.util.Collection#containsAll(Collection)
	 * @uml.property  name="heroes"
	 */
	public boolean containsAllheroes(Collection<? extends Hero> heroes) {
		return this.heros.containsAll(heroes);
	}

	/**
	 * Returns the number of elements in this collection.
	 * @return  the number of elements in this collection
	 * @see java.util.Collection#size()
	 * @uml.property  name="heroes"
	 */
	public int herosSize() {
		return heros.size();
	}

	public boolean addHero(Hero hero) {
		return this.heros.add(hero);
	}

	/**
	 * Removes a single instance of the specified element from this collection, if it is present (optional operation).
	 * @param element  to be removed from this collection, if present.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="heroes"
	 */
	public boolean removeHero(Combatant hero) {
		return this.heros.remove(hero);
	}


	/**
	 * Returns <tt>true</tt> if this collection contains the specified element. 
	 * @param element  whose presence in this collection is to be tested.
	 * @see java.util.Collection#contains(Object)
	 * @uml.property  name="shield"
	 */
	public boolean containsShield(Equipable shield) {
		return this.shields.contains(shield);
	}

	public boolean addShield(Shield shield) {
		return this.shields.add(shield);
	}

	/**
	 * Removes a single instance of the specified element from this collection, if it is present (optional operation).
	 * @param element  to be removed from this collection, if present.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="shield"
	 */
	public boolean removeShield(Equipable shield) {
		return this.shields.remove(shield);
	}

	public boolean addWeapon(Weapon weapon) {
		return this.weapons.add(weapon);
	}


	/**
	 * Removes a single instance of the specified element from this collection, if it is present (optional operation).
	 * @param element  to be removed from this collection, if present.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="weapon"
	 */
	public boolean removeWeapon(Equipable weapon) {
		return this.weapons.remove(weapon);
	}
	public boolean removeArmour(Equipable armour){
		return this.armours.remove(armour);
	}

	

	

	/**
	 * @uml.property  name="cloak"
	 * @uml.associationEnd  multiplicity="(0 -1)" inverse="player:game.Cloak"
	 */
	private CloakTreasure cloak=null;

	/**
	 * Getter of the property <tt>cloak</tt>
	 * @return  Returns the cloak.
	 * @uml.property  name="cloak"
	 */
	public CloakTreasure getCloak() {
		return cloak;
	}

	public void setCloak (CloakTreasure cloak){
		this.cloak=cloak;
	}

	
	/**
	 * @uml.property  name="heroeses"
	 */
	private List<Hero> heros;

	/** 
	 * Getter of the property <tt>heroeses</tt>
	 * @return  Returns the heroeses.
	 * @uml.property  name="heroeses"
	 */
	public List<Hero> getHeroes() {
		return heros;
	}

	/**
	 * @uml.property  name="potions"
	 */
	private List<Potion> potions;

	/** 
	 * Getter of the property <tt>potions</tt>
	 * @return  Returns the potions.
	 * @uml.property  name="potions"
	 */
	public List<Potion> getPotions() {
		return potions;
	}

	/**
	 * @uml.property  name="slainedMonsters"
	 */
	private List<Monster> deadMonsters =new LinkedList<Monster>();

	/** 
	 * Getter of the property <tt>slainedMonsters</tt>
	 * @return  Returns the slainedMonsters.
	 * @uml.property  name="slainedMonsters"
	 */
	public List<Monster> getDeadMonsters() {
		return deadMonsters;
	}

	/**
	 * @uml.property  name="treasures"
	 */
	private List<Treasure> treasures = new LinkedList<Treasure>();

	/** 
	 * Getter of the property <tt>treasures</tt>
	 * @return  Returns the treasures.
	 * @uml.property  name="treasures"
	 */
	public List<Treasure> getTreasures() {
		return treasures;
	}

	/**
	 * @uml.property  name="weapons"
	 */
	private List<Weapon> weapons;

	/** 
	 * Getter of the property <tt>weapons</tt>
	 * @return  Returns the weapons.
	 * @uml.property  name="weapons"
	 */
	public List<Weapon> getWeapons() {
		return weapons;
	}

	/**
	 * @uml.property  name="armours"
	 */
	private List<Armour> armours;

	/** 
	 * Getter of the property <tt>armours</tt>
	 * @return  Returns the armours.
	 * @uml.property  name="armours"
	 */
	public List<Armour> getArmours() {
		return armours;
	}

	/**
	 * @uml.property  name="shields"
	 */
	private List<Shield> shields;

	/** 
	 * Getter of the property <tt>shields</tt>
	 * @return  Returns the shields.
	 * @uml.property  name="shields"
	 */
	public List<Shield> getShields() {
		return shields;
	}

	/**
	 * @uml.property  name="sorceries"
	 */
	private List<Sorcery> sorceries;

	/** 
	 * Getter of the property <tt>sorceries</tt>
	 * @return  Returns the sorceries.
	 * @uml.property  name="sorceries"
	 */
	public List<Sorcery> getSorceries() {
		return sorceries;
	}

	/**
	 * @param gold
	 * @uml.property  name="gold"
	 */
	public void setGold(Integer gold) {
		this.gold = gold;
	}

	/**
	 * @return
	 * @uml.property  name="gold"
	 */
	public Integer getGold() {
		return gold;
	}

	/**
	 * @uml.property  name="gold"
	 */
	private Integer gold;
	
	public String listPotionToString(){
		String s="";
		int index=1;
		for(Potion p: this.getPotions()){
			s+=index+ ". " + p.toString() + "\r\n";
			index++;
		}
		return s;
		
	}
	public String listSorceryToString(){
		String s="";
		int index=1;
		for(Sorcery p: this.getSorceries()){
			s+=index+ ". " + p.toString() + "\r\n";
			index++;
		}
		return s;
		
	}
	
	public String listHeroesToString(){
		String s="";
		int index=1;
		for(Combatant p: this.getHeroes()){
			s+=index+ ". " + p.toString() + "\r\n";
			index++;
		}
		return s;
		
	}
	public String listLocationsToString(){
		String s="";
		int index=1;
		for(Location l: this.getLocations()){
			s+=index+ ". " + l.toString() + "\r\n";
			index++;
		}
		return s;
	}

	public String listEquipablesToString() {
		String s="";
		int index=1;
		for(Equipable l: this.getEquipables()){
			s+=index+ ". " + l.toString() + "\r\n";
			index++;
		}
		return s;
	}

	public String listTreasuresToString() {
		String s="";
		int index=1;
		for(Treasure l: this.getTreasures()){
			s+=index+ ". " + l.toString() + "\r\n";
			index++;
		}
		return s;
	}
	public List<Treasure> getEquipablesTreasures(){
		List<Treasure> listT = new LinkedList<Treasure>();
		for(Treasure treasure: this.getTreasures()){
			if(treasure instanceof EquipableTreasure){
				listT.add(treasure);
			}
		}
		return listT;
	}
	
	public String listTreasuresEquipablesToString() {
		String s="";
		int index=1;
		for(Treasure l: this.getEquipablesTreasures()){
				s+=index+ ". " + l.toString() + "\r\n";
				index++;
			
		}
		return s;
	}


	public void setSorceriesUnavaiables(List<Sorcery> sorceriesUnavaiables) {
		this.sorceriesUnavaiables = sorceriesUnavaiables;
	}

	public List<Sorcery> getSorceriesUnavaiables() {
		return sorceriesUnavaiables;
	}

	public void setUsedTreasures(List<Treasure> usedTreasures) {
		this.usedTreasures = usedTreasures;
	}

	public List<Treasure> getUsedTreasures() {
		return usedTreasures;
	}
	
	
}
